﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;

namespace Framework_Tool
{
    /// <summary>
    /// Interaction logic for UnitDelete.xaml
    /// </summary>
    public partial class UnitDelete : Page
    {
        public UnitDelete()
        {
            InitializeComponent();
            Database.FindID_UnitDelete(this);
        }

        private void mainContent_Loaded_1(object sender, RoutedEventArgs e)
        {
            viewUnit.FontWeight = FontWeights.Normal;
            addUnit.FontWeight = FontWeights.Normal;
            updateUnit.FontWeight = FontWeights.Normal;
            deleteUnit.FontWeight = FontWeights.ExtraBold;
            searchUnit.FontWeight = FontWeights.Normal;
        }

        private void viewUnit_Click_1(object sender, RoutedEventArgs e)
        {
            UnitView unitViewWindow = new UnitView();
            unitViewWindow.Content = null;
            mainContent.Children.Add(unitViewWindow.mainContent);
        }

        private void addUnit_Click_1(object sender, RoutedEventArgs e)
        {
            UnitAdd UnitAddWindow = new UnitAdd();
            UnitAddWindow.Content = null;
            mainContent.Children.Add(UnitAddWindow.mainContent);

        }

        private void updateUnit_Click_1(object sender, RoutedEventArgs e)
        {
            UnitUpdate UnitUpdateWindow = new UnitUpdate();
            UnitUpdateWindow.Content = null;
            mainContent.Children.Add(UnitUpdateWindow.mainContent);
        }

        private void searchUnit_Click_1(object sender, RoutedEventArgs e)
        {

        }

        private void unitDelete_Click_1(object sender, RoutedEventArgs e)
        {
            Database.DeleteUnit(this);
            unitIDDeleteCmbx.Items.Clear();
            Database.FindID_UnitDelete(this);
        }

        private void cancelUnitDelete_Click_1(object sender, RoutedEventArgs e)
        {
            unitIDDeleteCmbx.SelectedItem = null;
            unitDelete_CourseTitleTxt.Text = null;
            crseIDDeleteLbl.Content = null;
            unitStfDeleteListBox.Items.Clear();
            unitTitleDeleteTxt.Text = null;
            unitDeleteDescTxt.Text = null;
            unitDeletedLblGrid.Visibility = Visibility.Hidden;
        }

        private void unitIDDeleteCmbx_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (unitIDDeleteCmbx.Text != null)
            {
                Database.populateFields_UnitDelete(this);


                DataSet ds = Database.populateTeachingList_UnitDelete(this);

                foreach (DataRow myRow in ds.Tables["unitTeacher"].Rows)
                {
                    unitStfDeleteListBox.Items.Add(myRow[0].ToString());
                    // + "   \t" + myRow[1].ToString() + "\t\t" + myRow[2].ToString());
                }
            }
        }
    }
}
